package scenic;

import java.awt.Rectangle;

import scenic.color.ColorSpace;
import scenic.geom.Affine2;
import scenic.jni.Renderer;

/**
 * Applies a color space to the sub-graph. All rendering in the sub-graph 
 * is done in the specified color space. Currently experimental, do not use.
 */
public class SceneColorSpace extends SceneContainer {
	private ColorSpace colorSpace;
	
	void draw(DrawContext context, Affine2 transform, Rectangle visibleArea) {
		Rectangle bounds = getBounds(context, transform);
			
		if(bounds.width <= 0 || bounds.height <= 0)
			return;
		bounds = addSafetyMargin(bounds);
		if(context.renderer.beginSurface(context.context, bounds, Renderer.SURFACE_TYPE_COLOR) == 0)
			return;
		context.renderer.setColorSpace(context.context, true);
		super.draw(context, transform, bounds);
		context.renderer.color(context.context, 1.0f, 1.0f, 1.0f, 1.0f);
		context.renderer.drawSurface(context.context);
	}
	
	Rectangle getBounds(DrawContext context, Affine2 transform) {
		Rectangle result = super.getBounds(context, transform);

		return result;
	}
	
}
